﻿<!--- ==================================================
NAME:	get_messages.cfm
DESC:	This is the file that gets a message.
=================================================== --->
<cfsetting enablecfoutputonly="yes">

<!--- default data --->
<cfparam name="arguments.pi_division" type="any" default="">
<cfparam name="arguments.customerid" type="any" default="">
<cfparam name="arguments.contactid" type="any" default="">
<cfparam name="arguments.message_type" default="A">
<cfparam name="arguments.orderid" type="any" default="">
<cfparam name="arguments.invoice_number" type="any" default="">
<cfparam name="arguments.user" type="any" default="">

<cfquery name="asp_get_tsr_permissions" datasource="#request.dsn#">	
	execute asp_get_tsr_permissions  @itsr_id ='#arguments.user#'
</cfquery>

<cfif asp_get_tsr_permissions.recordCount>
	<cfset arguments.pi_division = asp_get_tsr_permissions.SALES_DIVISION[1]>
</cfif>

<!--- build xml statement --->
<cfscript>
xi_namespace='#trim(application.xi_namespace)#:MESSAGE:GetMessages';
xi_interface='GetMessages_OB';
xml = '<xtiinput>
	<inputheader>
		<actionset>
			<action>get_messages</action>
		</actionset>
	</inputheader>
	<inputdata>
		<system>#variables.system#</system>
		<pi_division>#arguments.pi_division#</pi_division>
		<customerid>#arguments.customerid#</customerid>
		<contactid>#arguments.contactid#</contactid>
		<msg>
			<message_type>#arguments.message_type#</message_type>
			<orderid>#arguments.orderid#</orderid>
			<invoice_number>#arguments.invoice_number#</invoice_number>
			<user>#arguments.user#</user>
		</msg>
	</inputdata>
</xtiinput>';
</cfscript>